package com.bree.erp.report.jasper;

import com.bree.erp.entity.PurchaseRequisition;
import com.bree.erp.report.vo.PurchaseRequisitionData;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

public class JRPurchaseRequisitionDataSource implements JRDataSource {
	
	private boolean one = true;
	
	private PurchaseRequisitionData data;

	
	public JRPurchaseRequisitionDataSource(PurchaseRequisition purchaseRequisition) {
		data = new PurchaseRequisitionData(purchaseRequisition);
	}
	
	@Override
	public Object getFieldValue(JRField field) throws JRException {
		
		if("purchaseRequisition".equals(field.getName())) {
			return data;
		}
		
		if("items".equals(field.getName())) {
			return data.getItems();
		}
		
		return null;
	}

	@Override
	public boolean next() throws JRException {
		
		boolean temp = one;
		
		one = false;
		
		return temp;
	}

}
